package dp.test70;

/**
 * @author code_yc
 * @version 1.0
 * @date 2020/7/22 12:35
 */
public class Solution1 {

    public int climbStairs(int n) {
        if (n < 2) return 1;
        int pre = 1;
        int next = 1;
        int cur = 0;
        for (int i = 2; i <= n; i++) {
            cur = pre + next;
            pre = next;
            next = cur;
        }
        return cur;
    }

    public int climbStairs2(int n) {
        if(n <= 1) return 1;
        int[] dp = new int[n + 1];
        dp[0] = dp[1] = 1;
        for(int i = 2; i <= n; i++){
            dp[i] = dp[i - 2] + dp[i - 1];
        }
        return dp[n];
    }
}
